using Dida.Dbg;

namespace Dida
{
	[Dxml.DidaObject]
	public class Locator : Actor
	{
		public Vector3D pos;
		public float size;
		public AniSocket<SimpleTransform> transform;

		[Dxml.AutoXmlConstructor]
		public Locator(Vector3D pos,float size,AniSocket<SimpleTransform> transform)
		{
			this.pos = pos;
			this.size = size;
			this.transform = transform;
		}

		public override void DrawDebug(IDebugDrawTarget dbgDraw)
		{
			dbgDraw.PushWorldMatrix(transform.Value.ToMatrix());
			dbgDraw.DrawLocator(pos, 1, Colour.CreateUInt32Colour(255,0,0));
			dbgDraw.PopWorldMatrix();
		}

		protected override SimpleTransform GetTransform()
		{
			return transform.Value;
		}

		public override Box BoundingBox
		{
			get
			{
				Vector3D wsPos = transform.Value.TransformPoint(pos);
				return Box.FromCenterAndSize(wsPos,new Vector3D(size,size,size));
			}
		}
	}
}